//
//  ViewController.m
//  ZBDrawingTool
//
//  Created by apple on 2018/6/5.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ViewController.h"
#import "ZBDrawingView.h"
#import <AVFoundation/AVFoundation.h>

#import "ZBDrawingBoard.h"

#import "ZBDrawingTool.h"
#import "ZBDrawingPaintTool.h"


@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *showImageView;

@property (nonatomic, strong) ZBDrawingView *drawView;
@property (nonatomic, strong) ZBDrawingBoard *drawBoard;

@property (nonatomic, strong)  ZBDrawingTool *tool1;
@property (nonatomic, strong)  ZBDrawingPaintTool *tool2;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //方案一
//    [self.view addSubview:self.drawView];
//    self.tool1 = [ZBDrawingTool drawingToolWithDrawingView:self.drawView];
//    self.drawView.backgroundColor = [UIColor redColor];
//    self.drawView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300);
    
    //方案二
    [self.view addSubview:self.drawBoard];
    self.tool2 = [ZBDrawingPaintTool drawingToolWithDrawingBoard:self.drawBoard];
    self.drawBoard.backgroundColor = [UIColor redColor];
    self.drawBoard.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300);
  
}

- (IBAction)cleanButtonClick:(UIButton *)sender {
    [self.tool2 cleanDrawingView];
    [self.tool1 cleanDrawingView];
}
- (IBAction)undoButtonClick:(UIButton *)sender {
    [self.tool2 undoDrawingView];
    [self.tool1 undoDrawingView];
}

- (IBAction)showImageClick:(UIButton *)sender {
    self.showImageView.image = [self.tool2 getDrawingImage];
   // self.showImageView.image = [self.tool1 getDrawingImage];
}
- (IBAction)saveButtonClick:(UIButton *)sender {
    [self.tool2 saveDrawingImageToAlumImage];
    [self.tool1 saveDrawingImageToAlumImage];
}

#pragma mark - lazy
- (ZBDrawingView *)drawView
{
    if(_drawView == nil)
    {
        _drawView = [[ZBDrawingView alloc]init];
    }
    return _drawView;
}

- (ZBDrawingBoard *)drawBoard
{
    if(_drawBoard == nil)
    {
        _drawBoard = [[ZBDrawingBoard alloc]init];
    }
    return _drawBoard;
}
@end
